<template>
	<div class="view">
		<div class="mask" @click="maskClick"></div>
		<div class="search-goods-mian">
			<div class="category">
				<text class="title-text">{{category.categoryTitle}}</text>
				<div class="category-content">
					<div :class="[item.isActive ? 'active-item':'item' ]" v-for="(item,index) in category.categoryList" @click="itemClick(index)"
					 :key="item" v-if="item.brandName">
						<text v-if="item.brandName" :class=" [item.isActive==true ? 'active-text':'item-text' ]">{{item.brandName}}</text>
					</div>
				</div>
			</div>
			<div class="selectPrice_content">
				<div><text class="title-text">价格区间(元)</text></div>
				<div class="priceContent">
					<div><input placeholder="最低价" class="minPrice" v-model="minPrice" type="number"></input></div>
					<div class="price_line"></div>
					<input class="minPrice" placeholder="最高价" v-model="maxPrice"></input>
				</div>
			</div>
			<div class="button_content">
				<div class="button_rest" @click="reset"><text class="button_title">重置</text></div>
				<div class="button_true" @click="enterClick"><text class="button_title">确定</text></div>
			</div>
		</div>
	</div>

</template>
<script>
	export default {
		name: 'searchGoods',
		data() {
			return {
				searchBrand:'',
				minPrice: '',
				maxPrice: '',
				category: {
					categoryTitle: '品牌推荐',
					categoryList: []
				}
			}
		},
		props: ['brandList'],
		created() { // 在实例创建完成后被立即调用
			this.category.categoryList = this.brandList
		},

		methods: {
			enterClick(){
				this.category.categoryList.forEach(item=>{
					if(item.isActive==true){
						this.searchBrand=item.brandId
					}
				})
				let search={
					brandId:this.searchBrand,
					maxPrice:this.maxPrice,
					minPrice:this.minPrice
				}
				
				this.$emit('loadProduct',search)
				this.$emit('hiddenClick')
			},
			reset() {
				this.minPrice = ''
				this.maxPrice = ''
				this.category.categoryList.forEach((item, i) => {
					item.isActive=false
				})
			},
			maskClick() {
				this.$emit('hiddenClick')
			},
			itemClick(e) { // 点击
				this.category.categoryList.forEach(item => {
					item.isActive = false
				})
				this.category.categoryList[e].isActive = true


			},
		},
		components: {},
	}
</script>

<style scoped>
	.view {
		flex: 1;
		width: 750px;
		display: flex;
		flex-direction: row;
	}

	.mask {
		width: 182px;
		opacity: 0.5;
		background-color: #7c7c7c;
		
	}

	.search-goods-mian {
		flex: 1;
		background-color: #fff;
		width: 568px;
		padding: 48px 24px 0 24px;
	}

	.title-text {
		font-size: 24px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
		opacity: 0.5;
	}
	.category{
		margin-top: 30px;
	}
	.category-content {
		margin-top: 29px;
		margin-bottom: 50px;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.category-item {
		border: 1px solid rgba(126, 128, 136, 1);
		opacity: 0.6;
		border-radius: 4px;
		text-align: center;
		margin-left: 10px;
		margin-bottom: 15px;
		box-sizing: border-box;
	}



	.button_content {
		width: 568px;
		position: absolute;
		bottom: 0;
		right: 0;
		display: flex;
		flex-direction: row;
		justify-content: space-around;

	}

	.button_rest {
		margin-bottom: 50px;
		border-radius: 4px;
		height: 74px;
		width: 246px;
		display: flex;
		justify-content: center;
		align-items: center;
		background-image: linear-gradient(to bottom right, rgba(196, 198, 204, 1), rgba(213, 215, 219, 1));

	}

	.button_title {

		color: white;
	}

	.button_true {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 50px;
		border-radius: 4px;
		height: 74px;
		width: 246px;
		background-image: linear-gradient(to bottom right, rgba(233, 88, 79, 1), rgba(241, 114, 80, 1));
	}

	/* 	.button button {
		width: 246px !important;
		height: 74px !important;
		background: linear-gradient(98deg, rgba(196, 198, 204, 1), rgba(213, 215, 219, 1));
		border-radius: 4px;
		font-size: 32px;
		font-family: PingFang SC;
		font-weight: 400;
		color: rgba(255, 255, 255, 1);
	}

	.button button:nth-of-type(2) {
		background: linear-gradient(129deg, rgba(233, 88, 79, 1), rgba(241, 114, 80, 1));
	}
 */
	.item {
		border-radius: 4px;
		text-align: center;
		margin-left: 10px;
		margin-bottom: 15px;
		border-style: solid;
		border-color: rgba(126, 128, 136, 1);
		border-width: 1px;
		background: rgba(231, 91, 83, 0.03);
		box-sizing: border-box;
	}

	.active-item {
		border-radius: 4px;
		text-align: center;
		margin-left: 10px;
		margin-bottom: 15px;
		border-style: solid;
		border-color: rgba(231, 91, 83, 1);
		border-width: 1px;
		background: rgba(231, 91, 83, 0.03);
		box-sizing: border-box;
	}

	.item-text {
		display: block;
		padding: 20px 44px 19px 46px;
		font-size: 24px;
		font-weight: 400;
		color: rgba(26, 26, 30, 1);
	}

	.active-text {
		display: block;
		padding: 20px 44px 19px 46px;
		font-size: 24px;
		font-weight: 400;
		color: rgba(231, 91, 83, 1);
	}

	.selectPrice_content {
		display: flex;
		width: 568px;
		flex-direction: column;
	}

	.priceContent {
		width: 500px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		height: 60px;
		align-items: center;
		margin-top: 20px;
	}

	.price_line {
		height: 8px;
		width: 50px;
		background-color: rgba(212, 215, 220, 0.2)
	}

	.minPrice {
		font-size: 20px;
		color: rgba(212, 215, 220, 0.5);
		display: flex;
		flex-direction: row;
		width: 200px;
		padding-left: 50px;
		height: 50px;
		border-radius: 40px;
		background-color: rgba(212, 215, 220, 0.2)
	}
</style>
